/******************************************************************************/
/* Files to Include                                                           */
/******************************************************************************/

#include <xc.h>           /* Global Header File */
#include <stdint.h>        /* For uint8_t definition */
#include <stdbool.h>       /* For true/false definition */

#include "system.h"        /* System funct/params, like osc/peripheral config */
#include "user.h"          /* User funct/params, such as InitApp */
#include "interrupts.h"

/******************************************************************************/
/* User Global Variable Declaration                                           */
/******************************************************************************/

/* i.e. uint8_t <variable_name>; */

/******************************************************************************/
/* Main Program                                                               */
/******************************************************************************/

uint8_t main(void)
{
	uint8_t	time1s = 100;
	uint8_t	color = 0;

    /* Configure the oscillator for the device */
    ConfigureOscillator();

    /* Initialize I/O and Peripherals for application */
	intInit();
    InitApp();

    /* TODO <INSERT USER APPLICATION CODE HERE> */
	TRISC = 0xF7;

    while(1)
    {
		if(t100hz)
		{
			/* 10ms wait */
			t100hz = false;
			if(--time1s == 0)
			{
				/* 1s wait */
				time1s = 100;

				/* change Color */
				color++;
				setColor((color >> 4) & 0x03, (color >>2) & 0x03, color & 0x03);

			}
		}
    }
	
	return 0;
}

